package com.pioneer.cloudstorage.utils;


import com.pioneer.cloudstorage.pojo.entity.FileContentIndex;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Component("customFileContentMapper")
public interface FileContentMapper extends ElasticsearchRepository<FileContentIndex, String> {

    /**
     * 根据文件ID查找索引
     */
    FileContentIndex findByFileId(Long fileId);

    /**
     * 根据用户ID和内容搜索
     */
    List<FileContentIndex> findByUserIdAndContentContaining(Long userId, String keyword);

    /**
     * 根据用户ID和文件名搜索
     */
    List<FileContentIndex> findByUserIdAndFileNameContaining(Long userId, String keyword);

    /**
     * 删除指定文件ID的索引
     */
    void deleteByFileId(Long fileId);

    /**
     * 根据用户ID删除所有索引
     */
    void deleteByUserId(Long userId);


}